//
//  SWTool.h
//  StormWatch
//
//  Created by 王岩 on 2024/8/29.
//

#import <Foundation/Foundation.h>
#define kFloatToStr(num) ([JYTool strWithFloat:num min:0 max:2])
#define kFloatToStrMax(num, x) ([JYTool strWithFloat:num min:0 max:x])
#define kFloatToStrMinMax(num, i, x) ([JYTool strWithFloat:num min:i max:x])
NS_ASSUME_NONNULL_BEGIN

@interface SWTool : NSObject
+ (BOOL)objectIsNullAndEmpty:(NSObject *)object;
+ (BOOL)validatePassword:(NSString *)password;

#pragma mark - 字符串辅助性工具
+ (NSMutableAttributedString *)attS1:(NSString *)str1
                                  s2:(NSString *)str2
                                  s3:(NSString *)str3
                                  f1:(UIFont * __nullable)f1
                                  c1:(UIColor * __nullable)c1
                                  f2:(UIFont * __nullable)f2
                                  c2:(UIColor * __nullable)c2
                                  f3:(UIFont * __nullable)f3
                                  c3:(UIColor * __nullable)c3;

+ (NSMutableAttributedString *)attS1:(NSString *)str1
                                  s2:(NSString *)str2
                                  f1:(UIFont * __nullable)f1
                                  c1:(UIColor * __nullable)c1
                                  f2:(UIFont * __nullable)f2
                                  c2:(UIColor * __nullable)c2;

+ (NSMutableAttributedString *)attS:(NSString *)str
                                  f:(UIFont * __nullable)f
                                  c:(UIColor * __nullable)c;

+ (NSMutableAttributedString *)attS:(NSString *)str
                                  f:(UIFont *)f
                                  c:(UIColor *)c
                                  h:(CGFloat)h;

// 加中划线
+ (NSMutableAttributedString *)attStrikeS1:(NSString *)str1
                                        s2:(NSString *)str2
                                        f1:(UIFont *)f1
                                        c1:(UIColor *)c1
                                        f2:(UIFont *)f2
                                        c2:(UIColor *)c2
                                        is:(BOOL)isFirst;

// 加中划线
+ (NSMutableAttributedString *)attStrikeS:(NSString *)str
                                        f:(UIFont * __nullable)f
                                        c:(UIColor * __nullable)c;

// 下划线
+ (NSMutableAttributedString *)attUnderS:(NSString *)str
                                       f:(UIFont * __nullable)f
                                       c:(UIColor * __nullable)c;
+ (NSMutableAttributedString *)attUnderS:(NSString *)str1
                                      s2:(NSString *)str2
                                      s3:(NSString *)str3
                                      f1:(UIFont * __nullable)f1
                                      c1:(UIColor * __nullable)c1
                                      f2:(UIFont * __nullable)f2
                                      c2:(UIColor * __nullable)c2
                                      f3:(UIFont * __nullable)f3
                                      c3:(UIColor * __nullable)c3
                                      lc:(UIColor *)lc;

+ (NSDictionary *)attributesF:(UIFont *)f c:(UIColor *)c;
+ (NSDictionary *)attributesF:(UIFont *)f c:(UIColor *)c h:(CGFloat)h;

+ (NSAttributedString *)createTextAttibute:(NSString *)string dict:(NSDictionary *)dict;

/// 限制字符串显示字数
+ (NSString * __nullable)limitMax:(NSInteger)max string:(NSString *)string;

#pragma mark - 数字显示
/**
 小数浮点数转化成字符串
 @param num 浮点数
 @param min 最小小数位数
 @param max 最大小数位数
 */
+ (NSString *)strWithFloat:(double)num min:(NSInteger)min max:(NSInteger)max;

+ (BOOL)checkEmptyString:(NSString *)string;


+ (NSString *)formatterMoney:(NSString *)money;


/// 压缩图片尺寸
/// @param image 图片对象
/// @param maxLength 最大体积 单位KB
+ (NSData*)compressImageQuality:(UIImage*)image toByte:(NSInteger)maxLength;


+ (void)showAlertTitle:(nullable NSString *)title
               Message:(nullable NSString *)message
           CancelTitle:(nullable NSString *)cancelTitle
          CancelAction:(nullable void(^)(void))cancelAction
             SureTitle:(nullable NSString *)sureTitle
            SureAction:(nullable void(^)(void))sureAction;


+ (void)showAlertTitle:(nullable NSString *)title
               Message:(nullable NSString *)message
             SureTitle:(nullable NSString *)sureTitle
            SureAction:(nullable void(^)(void))sureAction;

+(UIWindow *)searchKeyWindow;

+ (NSString *)localizedStringForKey:(NSString *)key Table:(NSString *)tab;

+ (unsigned int)hexChangeToInt:(NSString *)hex;
/**
 十进制转二进制
 
 @return 二进制字符串
 */
+ (NSString *)decimalToBinary:(NSString *)string;
/*
 二进制转十进制
 
 @return 十进制字符串
 */
+ (NSString *)binaryToDecimal:(NSString *)string;


+ (NSString *)timeWithYearMonthDayCountDown:(NSString *)timestamp Format:(NSString *)format;
@end

NS_ASSUME_NONNULL_END
